package com.wujilin.okra.activity;

import static com.wujilin.okra.Okra.EXTRA_OBJECTIVE_ID;
import static com.wujilin.okra.Okra.REQUEST_OKRA;
import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;

/**
 * @author Belin Wu
 */
public class BaseActivity extends Activity {
    /**
     * 根据标签获取Fragment。
     * 
     * @param tag 标签
     * @return Fragment
     */
    public Fragment getFragment(String tag) {
    	return getFragmentManager().findFragmentByTag(tag);
    }
    
    /**
     * 根据ID获取Fragment。
     * 
     * @param id ID
     * @return Fragment
     */
    public Fragment getFragment(int id) {
    	return getFragmentManager().findFragmentById(id);
    }
    
    /**
     * Called when viewing a Okra.
     * 
     * @param id The id of Okra
     */
	public void onOkraSelected(long id) {
		Intent intent = new Intent(this, OkraActivity.class);
		intent.putExtra(EXTRA_OBJECTIVE_ID, id);
		startActivityForResult(intent, REQUEST_OKRA);
	}
}
